@tool
class_name AdditionalEffect_Action_ReleaseSkill
extends AdditionalEffect_Action

#region 属性
@export var skill_id:String
## 当没有这个Skill时是否自动添加该技能
@export var is_auto_add_when_no_skill:bool = true
@export var release_args:Dictionary[String,Variant]
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
## 初始化
func init(args:Dictionary = {}):
	if super(args):
		self.args.set("StateAction",action)
		for key in release_args.keys():
			self.args.set(key,release_args.get(key))
		return true
	return false
## 检查能否执行添加效果，默认为true
func can_excute() -> bool:
	return super()
## 执行添加效果
func excute() -> bool:
	if super():
		target = target as Entity
		var skill_component:SkillComponent = target.get_component(SkillComponent)
		if skill_component:
			if is_auto_add_when_no_skill:
				skill_component.get_skill_agent().add_skill(skill_id)
			skill_component.get_skill_agent().release_skill(skill_id,self.args)
		return true
	else:
		return false
## 取消执行的效果
func cancel_excute() -> bool:
	if super():
		target = target as Entity
		var skill_component:SkillComponent = target.get_component(SkillComponent)
		if skill_component:
			skill_component.get_skill_agent().cancel_skill(skill_id)
		return true
	else:
		return false
#endregion
#region 公共方法
#endregion
#region 私有方法
#endregion
#region 生命周期函数
func _init() -> void:
	if Engine.is_editor_hint():
		resource_local_to_scene = true
#endregion
